//
//  PersonalDataViewController.m
//  安好
//
//  Created by 马晓良 on 14-11-10.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "PersonalDataViewController.h"
#import "PersonalDataHeaderView.h"
#import "EditPersonalDataViewController.h"
#import "PersonalDataCell.h"
#import "XHDrawerController.h"
#import "MainViewController.h"
#import "CustomActionSheetView.h"
#import "BaseNavigation.h"
#import "AFURLSessionManager.h"
#import "ShowBigHeaderPicViewController.h"
#import "XHImageViewer.h"
#import "PictureViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
@interface PersonalDataViewController ()<UITableViewDataSource,UITableViewDelegate,UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,controlRefresh,XHImageViewerDelegate>
{
    // 存放头像
    NSMutableArray *imageArrays;
    // 控制头像放大
    CGRect frame_first;
    UIImageView *fullImageView;
    BOOL uploadImage;
}
/**
 *  定义一个tableView显示数据
 */
@property (strong, nonatomic) IBOutlet UITableView *personalDataTableView;
/**
 *  封装的tableView的头部视图
 */
@property (nonatomic, strong) PersonalDataHeaderView *headerView;

//@property (nonatomic, strong) PictureViewController  *picViewController;
///**
// *  自定义的actionSheet
// */
//@property (nonatomic, strong) CustomActionSheetView *customActionSheet;
@property (nonatomic, strong) UIView *blueView;
@end

@implementation PersonalDataViewController
- (PersonalDataHeaderView *)headerView{
    if (_headerView == nil) {
        _headerView = [[PersonalDataHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 176)];
    }
    return _headerView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
   self.blueView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)];
    self.blueView.backgroundColor = [ClassMethodsViewController colorWithHexString:NACIGATIONBAR_BACKGROUNDCOLOR_16];
    imageArrays = [NSMutableArray array];
    [self perActionView];
    self.dataTypeArray = @[@"性      别",@"出生年月",@"地      区",@"身 份 证",@"个人邮箱",@"手机号码"];
    MyNSLog("===%d", self.userDetailObject.birthday.length);
    self.personalDataTableView.delegate = self;
    self.personalDataTableView.dataSource = self;
    self.personalDataTableView.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:200/255.0f  green:200/255.0f  blue:184/255.0f alpha:1.0f];
    // 隐藏黑线条
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    self.navigationItem.title = @"个人资料";
    [self.view addSubview:self.personalDataTableView];
    [self setNaviBarAttribute];
//    [self.personalDataTableView registerNib:[UINib nibWithNibName:@"PersonalDataCell" bundle:nil] forCellReuseIdentifier:@"personalDataCell"];
    [self.view addSubview:self.blueView];

    /**
     *  自定义的UIActionSheet 待实现
     */
//    [self setActionSheetView];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self perHiddenActionView];
}


- (void)controlRefresh{
    [self _parsePersonalDataSource:kBaseURL];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - 设置naviBar 并实现左右naviBar button方法 -
- (void)setNaviBarAttribute{
    /**
     *  设置左NaviBar和右naviBar
     */
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    leftButton.frame = CGRectMake(0, 0, 23, 23);
    [leftButton setImage:[UIImage imageNamed:@"公用_返回"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(handleLeftButtonAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 0, 23, 23);
    [rightButton setImage:[UIImage imageNamed:@"公用_编辑"] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(handleRightButtonAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
}

#pragma #pragma mark - naviBar按钮的执行方法 -
/**
 *  返回主页面
 */
- (void)handleLeftButtonAction{
    [self.drawerController closeDrawerAnimated:YES completion:nil];
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)handleRightButtonAction{
    EditPersonalDataViewController *editPersonalDataVC = [[EditPersonalDataViewController alloc] init];
    editPersonalDataVC.delegate = self;
    editPersonalDataVC.userDetailObject = self.userDetailObject;
    [self.navigationController pushViewController:editPersonalDataVC animated:YES];
}


#pragma mark - tabelView的代理方法 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *indentify = @"personalDataCell";
    PersonalDataCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];
    if (!cell) {
        if (kScreenWidth == 414) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"PersonalDataCell" owner:self options:nil] lastObject];
        }else{
            cell = [[[NSBundle mainBundle] loadNibNamed:@"PersonalDataCell" owner:self options:nil] firstObject];
        }
    }
    cell.attributeTypeLabel.text = [self.dataTypeArray objectAtIndex:indexPath.row];
    if(indexPath.row == 0){
        if ([self.userDetailObject.gender isEqualToString:@"0"]) {
            cell.contentView.hidden = YES;
        }else {
            cell.contentView.hidden = NO;
            if([self.userDetailObject.gender isEqualToString:@"1"]){
                cell.informationContentLabel.text = @"男";
            }else if([self.userDetailObject.gender isEqualToString:@"2"]){
                cell.informationContentLabel.text = @"女";
            }
        }
    }else if (indexPath.row == 1){
        if (self.userDetailObject.birthday.length <= 1) {
            cell.contentView.hidden = YES;
        }else{
            cell.contentView.hidden = NO;
            cell.informationContentLabel.text = self.userDetailObject.birthday;
        }
    }else if (indexPath.row == 2){
        if ([self.userDetailObject.address isEqualToString:@""]) {
            cell.contentView.hidden = YES;
        }else{
            cell.contentView.hidden = NO;
            cell.informationContentLabel.text = self.userDetailObject.address;
        }
    }else if (indexPath.row == 3){
        if ([self.userDetailObject.idcard isEqualToString:@""]) {
            cell.contentView.hidden = YES;
        }else{
            cell.contentView.hidden = NO;
            cell.informationContentLabel.text = self.userDetailObject.idcard;
        }
    }else if (indexPath.row == 4){
        if (self.userDetailObject.email.length < 1) {
            cell.contentView.hidden = YES;
        }else{
            cell.contentView.hidden = NO;
            cell.informationContentLabel.text = self.userDetailObject.email;
        }
    }else if (indexPath.row == 5){
        if ([self.userDetailObject.mobile isEqualToString:@""]) {
            cell.contentView.hidden = YES;
        }else {
            cell.contentView.hidden = NO;
             cell.informationContentLabel.text = self.userDetailObject.mobile;
        }
    }
    return cell;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (kScreenWidth == 414) {
        return 175;
    }else{
        return 152;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0 && [self.userDetailObject.gender isEqualToString: @"0"]) {
        return 0;
    }else if (indexPath.row == 1 && self.userDetailObject.birthday.length <= 1){
        return 0;
    }else if (indexPath.row == 2 && [self.userDetailObject.address isEqualToString:@""]){
        return 0;
    }else if (indexPath.row == 3 && [self.userDetailObject.idcard isEqualToString:@""]){
        return 0;
    }else if (indexPath.row == 4 && self.userDetailObject.email.length < 1 ){
        return 0;
    }else if (indexPath.row == 5 && [self.userDetailObject.mobile isEqualToString:@""]){
        return 0;
    }else{
        if (kScreenWidth == 414) {
            return 54;
        }else{
            return 44;
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
    
}

//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64 - self.personalDataTableView.bounds.size.height)];
//    view.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
//    return view;
//}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    self.headerView.backgroundColor = [ClassMethodsViewController colorWithHexString:NACIGATIONBAR_BACKGROUNDCOLOR_16];
    // 为头像添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandleAction:)];
    tap.numberOfTapsRequired = 1;
    
    
    BOOL isHaveUserImage = [[UserManager shareInstance]isHaveUserImage];
    if (isHaveUserImage == YES) {
        UIImage * userImage = [[UserManager shareInstance]getUserImage];
        [self.headerView.headerImageView setImage:userImage];
    }else{
        UserModel * usermodel = [[UserManager shareInstance]getUserInfo];
        UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:usermodel.avatar]]];
        [self.headerView.headerImageView setImage:image];
    }
    [self.headerView.headerImageView addGestureRecognizer:tap];
    [self getimage:^(UIImage *image) {
        /**
         *  修改头像并上传服务器
         */
//        self.headerView.headerImageView.image = image;
        dispatch_queue_t queue = dispatch_get_main_queue();
        dispatch_async(queue, ^{
            [self postImageView:image];
        });
    }];
    
    NSString *string = [NSString stringWithFormat:@"%@",self.userDetailObject.threads];
    if ([string isEqualToString:@"(null)"]) {
        string = [NSString stringWithFormat:@""];
    }
    self.headerView.topicView.dataMessage.text = string;
    self.headerView.topicView.dataMessage.numberOfLines = 1;
    CGSize size = CGSizeMake(333333, 12);
    //获取当前文本的属性
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12],NSFontAttributeName,nil];
    //获取文本需要的size
    CGSize redSize = [string boundingRectWithSize:size options:NSStringDrawingTruncatesLastVisibleLine |NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
    if (kScreenWidth == 414) {
        self.headerView.topicView.frame = CGRectMake(kScreenWidth / 2 - redSize.width - 50, 117, redSize.width + 30, 12);
    }else{
        self.headerView.topicView.frame = CGRectMake(kScreenWidth / 2 - redSize.width - 50, 105, redSize.width + 30, 12);
    }
    self.headerView.nameLabel.text = self.userDetailObject.username;
    self.headerView.lineImageView.image = [UIImage imageNamed:@"登录_分割线"];
    self.headerView.integralView.dataMessage.text = self.userDetailObject.creadits;
    self.headerView.smallImageView.image = [UIImage imageNamed:@"登录_分割线"];
    //    self.headerView.contentLabel.text = @"你如安好，我便是晴天";
    if (self.userDetailObject.bio.length == 0) {
        self.headerView.contentLabel.text = @"暂无个性签名";
    }else {
        self.headerView.contentLabel.text = self.userDetailObject.bio;
    }
    return self.headerView;
}

#pragma mark - 头像的点击事件执行方法 -
- (void)tapHandleAction:(UIGestureRecognizer *)sender{
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate: self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"照相机",@"图片库",@"查看大头像", nil];
    sheet.tag = 255;
    [sheet showInView: [[UIApplication sharedApplication].delegate window]];

}


#pragma mark - UIActionSheet 的代理方法 -
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (actionSheet.tag == 255) {
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        switch (buttonIndex) {
            case 0:// 本地相机
            { // 跳转到相机
                AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
                if (authStatus != AVAuthorizationStatusAuthorized)
                {
                    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"相机被禁用"
                                                                   message:@"请在iPhone的“设置-隐私-相机”中允许安好访问您的相机。"
                                                                  delegate:nil
                                                         cancelButtonTitle:@"确定"
                                                         otherButtonTitles:nil, nil];
                    [alert show];
                }else{
                        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
                            UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
                            pickerImage.delegate = self;
                            pickerImage.allowsEditing = YES;
                            //pickerImage.mediaTypes              默认是静态图片，指定摄像头获取获取数据类型
                            pickerImage.sourceType = UIImagePickerControllerSourceTypeCamera;//指定使用相机
                            [self presentViewController:pickerImage animated:YES completion:nil];
                        }
                        else{
                            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"没有摄像头或摄像头损坏" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
                            [alert show];
                        }

                    }
                 return;
            }
            case 1:// 本地相册
            { // 跳转到相册页面
                imagePickerController.delegate = self;
                imagePickerController.allowsEditing = YES;
                imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
                [self presentViewController:imagePickerController animated:YES completion:^{}];
                return;
                
            }
            case 2:
            {
//                ShowBigHeaderPicViewController *showPicVC = [[ShowBigHeaderPicViewController alloc] init];
//                showPicVC.headerImage = self.headerView.headerImageView.image;
//                [self presentViewController:showPicVC animated:YES completion:nil];
                
                
                // 此法有点小问题
//                [imageArrays removeAllObjects];
//                [imageArrays addObject:self.headerView.headerImageView];
//                XHImageViewer *imageViewer = [[XHImageViewer alloc] init];
//                imageViewer.delegate = self;
//                [imageViewer showWithImageViews:imageArrays selectedView:nil];
                
                UIImageView *imageView = (UIImageView *)self.headerView.headerImageView;
                frame_first = CGRectMake(self.headerView.headerImageView.origin.x , self.headerView.headerImageView.origin.y + 64, imageView.frame.size.width, imageView.frame.size.height);
                
                fullImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, [UIScreen mainScreen].bounds.size.height)];
                fullImageView.backgroundColor = [UIColor blackColor];
                fullImageView.userInteractionEnabled=YES;
                [fullImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionTapAction:)]];
                fullImageView.contentMode = UIViewContentModeScaleAspectFit;
                
                if (![fullImageView superview]) {
                    fullImageView.image = imageView.image;
                    [self.view.window addSubview:fullImageView];
                    fullImageView.frame = frame_first;
                    [UIView animateWithDuration:0.5 animations:^{
                        fullImageView.frame = CGRectMake(0, 0, kScreenWidth, [UIScreen mainScreen].bounds.size.height);
                    } completion:^(BOOL finished) {
                        [UIApplication sharedApplication].statusBarHidden = YES;
                    }];
                    
                }

//                self.headerView.headerImageView.layer.borderWidth = 3;
//                self.headerView.headerImageView.layer.masksToBounds = NO;
//                self.picViewController = [[PictureViewController alloc] initWithThumbImage:self.headerView.headerImageView.image imageView:self.headerView.headerImageView largeImagePath:nil];
//                self.picViewController.delegate = self;
                return;
            }
                
        }
    
    }
}


-(void)actionTapAction:(UITapGestureRecognizer *)sender{
    [UIView animateWithDuration:0.5 animations:^{
        fullImageView.frame=frame_first;
    } completion:^(BOOL finished) {
        [fullImageView removeFromSuperview];
    }];
    [UIApplication sharedApplication].statusBarHidden = NO;
}


//-(void)PictureViewDidDismiss{
//    self.headerView.headerImageView.layer.masksToBounds = YES;
//    self.headerView.headerImageView.layer.borderWidth = 2;
//    self.headerView.headerImageView.layer.cornerRadius = 30;
//    self.picViewController = nil;
//}

#pragma mark - 获取本地相册的方法 -
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    //得到图片（UIImagePickerControllerOriginalImage这个参数是获取整个图片，UIImagePickerControllerEditedImage获取截取的图片）
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    //动态移动，也就是返回
    [self dismissViewControllerAnimated:YES completion:^{
        [[UserManager shareInstance] deleteUserImage];
    self.headerImage(image);
    }];
}

// block 传值
- (void)getimage:(backImage)image{
    self.headerImage = image;
}

#pragma mark - 网路数据请求 -
- (void)_parsePersonalDataSource:(NSString *)urlString{
    MyNSLog("刷新了");
    // 获取url地址
    NSString * postURL = [NSString stringWithFormat:@"%@user/",urlString];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *parameters = @{@"platform": kPlatform,@"version":kVersion};
    [manager POST:postURL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]) {
            alertContent([responseObject objectForKey:@"msg"]);
        }else{
            NSDictionary * dataDic = [responseObject objectForKey:@"data"];
            [self.userDetailObject setValuesForKeysWithDictionary:dataDic];
        }
        [self setInformationData];
        [self.personalDataTableView reloadData];
    } failure:nil];
}


#pragma mark - 显示数据 -
- (void)setInformationData{
    self.headerView.nameLabel.text = self.userDetailObject.username;
    if (self.userDetailObject.bio.length == 0) {
        self.headerView.contentLabel.text = @"你如安好，我便是晴天";
    }else{
        self.headerView.contentLabel.text = self.userDetailObject.bio;
    }
}


#pragma mark - 上传头像 -
- (void)postImageView:(UIImage *)image{
    [self perShowActionView];
    NSData* imageData = UIImageJPEGRepresentation(image, 0.5);
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
    UserModel * usermodel = [[UserManager shareInstance]getUserInfo];
    NSString * uid = usermodel.uid;
    NSString * imageName = [NSString stringWithFormat:@"%@.png",uid];
    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:imageName];
    [UIImagePNGRepresentation(image)writeToFile: filePath atomically:YES];
    NSDictionary *dic = @{@"platform": kPlatform,@"version":kVersion};
    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@user/uploadavatar/",kBaseURL] parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        [formData appendPartWithFileData:imageData name:@"file" fileName:@"headerImage.png" mimeType:@"image/png"];
    } error:nil];
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    NSProgress *progress = nil;
    NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (error) {
             MyNSLog("Error: %@", error);
        }else{
            //图片上传成功
            NSString *msg=[NSString stringWithFormat:@"%@",[responseObject valueForKey:@"msg"]];
            if ([msg isEqualToString:@"上传成功"]) {
                 self.headerView.headerImageView.image = image;
                [self perHiddenActionView];
                MyNSLog("上传成功");
                
                UserModel * usermodel = [[UserManager shareInstance]getUserInfo];
                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
                NSString * uid = usermodel.uid;
                NSString * imageName = [NSString stringWithFormat:@"%@.png",uid];
                NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:imageName];
                // 保存文件的名称
                [UIImagePNGRepresentation(image)writeToFile: filePath atomically:YES];
                
                    }else{
                MyNSLog("上传失败");
                [self perHiddenActionView];
            }
        }
    }];
    [uploadTask resume];
}

/**
 *  加载中
 */
- (void)perActionView
{
    self.mbPro = [[MBProgressHUD alloc]initWithView:self.view];
    [self.mbPro setLabelText:@"头像上传中.."];
    [self.navigationController.view.superview addSubview:self.mbPro];
}
/**
 *  显示加载中
 */
- (void)perShowActionView
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    self.mbPro.center=self.view.center;
    [self.mbPro show:YES];
}

/**
 *  隐藏加载中
 */
- (void)perHiddenActionView
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    [self.mbPro hide:YES];
}

//  控制头部的颜色视图的大小
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    self.blueView.frame = CGRectMake(0, 0, kScreenWidth,-scrollView.contentOffset.y);
}


///**
// *  自定义UIActionSheet 待实现
// */
//- (void)setActionSheetView{
//    self.customActionSheet = [[CustomActionSheetView alloc] initWithFrame:CGRectMake(0, kScreenHeight - 157, kScreenWidth, 157)];
//    [self.customActionSheet.changeHeadPortraitButton addTarget:self action:@selector(changeHeadPortraitButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.customActionSheet.lookBigHeadPortraitButton addTarget:self action:@selector(lookBigHeadPortraitButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.customActionSheet.cancelButton addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:self.customActionSheet];
//}
//
//- (void)changeHeadPortraitButtonAction:(UIButton *)sender{
//    NSLog(@"firstButton");
//}
//
//- (void)lookBigHeadPortraitButtonAction:(UIButton *)sender{
//    NSLog(@"secondButton");
//}
//
//- (void)cancelButtonAction:(UIButton *)sender{
//    NSLog(@"取消");
//}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
